import service from '../../service'
const state = {
  count: 0,
  username: '',
  banner: []
}
const actions = {

  increase ({commit, a, b}) {
    console.log(a, b)
    commit('HOME_INCREASE')
  },
  getUserName (context) {
    service.get('/v1/getUser')
      .then((res) => {
        context.commit('HOME_GETUSERNAME', res.userName)
      })
  },
  getBanner ({context}) {
    service.get('/v1/home/banner')
      .then((res) => {
        context.commit('HOME_GETBANNER', res)
      })
  }

}
const mutations = {

  HOME_INCREASE: (state) => {
    state.count++
  },
  HOME_GETUSERNAME: (state, username) => {
    state.userName = username
  },
  HOME_GETBANNER: (state, res) => {
    state.banner = res
  }
}

export default {
  state,
  actions,
  mutations
}
